package com.situ.model;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.enums.SqlLike;
import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.situ.utils.AuditEntity;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * 商品分类模型
 */

@Getter
@Setter
@TableName("product_category")
public class ProductCategory extends AuditEntity{
    @TableId(type = IdType.AUTO)
    private Integer id; //分类id

    @TableField(whereStrategy = FieldStrategy.NOT_EMPTY, condition = SqlCondition.LIKE)
    private String name; //分类名称

    @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
    private Integer parentId; //父级分类id (0为根)

    @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
    private Integer sort; //排序权重

    @TableField(whereStrategy = FieldStrategy.NOT_EMPTY)
    private Integer isShow; //是否显示 (1：是  0：否)

    @TableField(exist = false) //不存在数据库中
    @JsonManagedReference //解决循环引用
    private List<ProductCategory> children; //子级分类

    @TableField(exist = false)
    @JsonBackReference
    private ProductCategory parent; //父级分类
}
